home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
xmsif.exe
/
XMSTEST3.C
< prev
Wrap
C/C++ Source or Header
|
1991-12-08
|
23KB
|
607 lines
/***************************************************************************
* xmstest3.c *
* MODULE: XMSIF *
* OS: DOS *
* VERSION: 1.0 *
* DATE: 12/08/91 *
* *
* Copyright (c) 1991 James W. Birdsall. All Rights Reserved. *
* *
* Requires xmsif.h, testutil.h, and xmstest.h to compile. *
* Compiles under Borland C++ 2.0, Turbo C 2.0, or MSC 6.00A. *
* *
* Regression test and example for XMSIF. See XMSTEST.C for more detail. *
* *
***************************************************************************/
/*
** system includes <>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
** custom includes ""
*/
#include "xmsif.h"
#include "xmstest.h"
#include "testutil.h"
/*
** local #defines
*/
/*
** misc: copyright strings, version macros, etc.
*/
/*
** typedefs
*/
/*
** global variables
*/
extern int testno;
extern char *gblmsg;
/*
** static globals
*/
/*
** function prototypes
*/
/*
** functions
*/
/***************************************************************************
* FUNCTION: DO_UMB_TESTS *
* *
* DESCRIPTION: *
* *
* Does UMB tests. *
* *
* ENTRY: *
* *
* None. *
* *
* EXIT: *
* *
* Void. *
* *
* CONSTRAINTS/SIDE EFFECTS: *
* *
***************************************************************************/
void do_UMB_tests(void)
{
unsigned long largest, allsize;
unsigned long allsize2;
unsigned long finalsize;
void far *handle;
int status;
int haveUMB = 0;
int goodallcore = 1;
gblmsg = " UMB TESTS";
/* are there UMBs in this system? */
TESTHEADER();
printf("Testing UMBcoreleft() and UMBallcoreleft(), determining whether\n");
printf("there are UMBs in this system.\n");
largest = UMBcoreleft();
weirdcodechk("UMBcoreleft()", 0, (void far *) NULL, 0, 0);
allsize = UMBallcoreleft();
if (_XMMerror != 0)
{
printf("UMBallcoreleft() returned unexpected code 0x%X\n",
(unsigned int) _XMMerror);
printf("Another broken system. *sigh*.\n");
printf("Values returned by UMBallcoreleft() are junk.\n");
allsize = ((largest == 0L) ? 0L : (384L * 1024L));
goodallcore = 0;
}
if ((largest == 0L) && (allsize == 0L))
{
printf("No UMBs found.\n");
}
else
{
haveUMB = 1;
}
if (allsize < largest)
{
printf("UMBallcoreleft() reports total size smaller than size of\n");
printf("largest UMB (from UMBcoreleft()).\n");
exit(3);
}
/* the theoretical max on UMBs is 384K (1024K - 640K) */
if (((allsize & 0xF) != 0L) || (allsize > (384L * 1024L)))
{
printf("UMBallcoreleft() returned weird value %lu\n", allsize);
exit(3);
}
else if (goodallcore != 0)
{
printf("UMBallcoreleft() reports %lu bytes in UMBs.\n", allsize);
}
if (((largest & 0xF) != 0L) || (largest > (384L * 1024L)))
{
printf("UMBcoreleft() returned weird value %lu\n", largest);
exit(3);
}
else
{
printf("UMBcoreleft() reports largest UMB is %lu bytes.\n", largest);
}
TESTTAILER();
/* try allocating a UMB */
TESTHEADER();
printf("Testing UMBalloc().\nShould %s.\n",
((haveUMB == 0) ? "fail" : "succeed"));
handle = UMBalloc(((haveUMB == 0) ? (largest) : (largest - 1)), &finalsize);
weirdcodechk("UMBalloc()", 0, (void far *) NULL, 0, 0);
if (handle == (void far *) NULL)
{
if (haveUMB != 0)
{
printf("UMBalloc() returned NULL.\n");
exit(3);
}
}
else
{
if (haveUMB == 0)
{
printf("UMBalloc() didn't return NULL.\n");
exit(3);
}
}
if (finalsize != largest)
{
printf("Size rounding didn't happen.\n");
UMBfree(handle);
exit(3);
}
if (goodallcore != 0)
{
allsize2 = UMBallcoreleft();
weirdcodechk("UMBallcoreleft()", 0, (void far *) NULL, 0, 0);
if (allsize2 != (allsize - finalsize))
{
printf("Total dropped weirdly from %lu to %lu\n", allsize,
allsize2);
UMBfree(handle);
exit(3);
}
}
TESTTAILER();
/* free it */
if (haveUMB != 0)
{
TESTHEADER();
printf("Testing UMBfree().\nShould succeed.\n");
status = UMBfree(handle);
TRIPLECHECK("UMBfree()", status, 0, (void far *) NULL, 0, 0);
if (goodallcore != 0)
{
allsize2 = UMBallcoreleft();
weirdcodechk("UMBallcoreleft()", 0, (void far *) NULL, 0, 0);
if (allsize2 != allsize)
{
printf(
"Total before UMBalloc(): %lu Total after UMBfree(): %lu\n",
allsize, allsize2);
exit(3);
}
}
}
return;
} /* end of do_UMB_tests() */
/***************************************************************************
* FUNCTION: DO_ICOPY_TESTS *
* *
* DESCRIPTION: *
* *
* Tests interval copy functions (_XMMicopy() and macros). *
* *
* ENTRY: *
* *
* None. *
* *
* EXIT: *
* *
* Void. *
* *
* CONSTRAINTS/SIDE EFFECTS: *
*